
#ifndef GAMESTATEMANAGER_HPP_
#define GAMESTATEMANAGER_HPP_

#include <vector>
#include <list>
#include "GameState.hpp"
#include <OIS/OISEvents.h>

/*
 * TODO:
 * - ensure that any state that is removed from the stack of active states is allowed to gracefully end it's run (i.e. some fade out animation or whatever)
 */
class GameStateManager
{
	public:

		void AddState(GameState*);
		void RemoveState(int);
		void ChangeState(int state);
		void SetActiveState(int state) { ClearActiveStates(); m_ActiveGameState.push_back(m_GameState[state]); }
		void ClearActiveStates() { m_ActiveGameState.clear(); }

		void RunActiveStates(double);

		bool InjectKeyPressed(const OIS::KeyEvent &keyEventRef) { return m_ActiveGameState.front()->keyPressed(keyEventRef); }
		bool InjectKeyReleased(const OIS::KeyEvent &keyEventRef) { return m_ActiveGameState.front()->keyReleased(keyEventRef); }

		bool InjectMouseMoved(const OIS::MouseEvent &evt)  { return m_ActiveGameState.front()->mouseMoved(evt); }
		bool InjectMousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id) { return m_ActiveGameState.front()->mousePressed(evt, id); }
		bool InjectMouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id) { return m_ActiveGameState.front()->mouseReleased(evt, id); }

		int GetActiveState() { return m_ActiveState; } 
	private:
		int m_ActiveState;
		std::vector<GameState*> m_GameState;
		std::list<GameState*> m_ActiveGameState;
};

#endif /* GAMESTATEMANAGER_HPP_ */
